{extend name="common/base"}
{block name="page-content-main"}
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <form id="my-form" class="am-form tpl-form-line-form" method="post">
                    <div class="widget-body">
                        <fieldset>

                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">票券图片 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <div class="am-form-file">
                                        <button type="button"
                                                class="upload-file am-btn am-btn-secondary am-radius">
                                            <i class="am-icon-cloud-upload"></i> 选择图片
                                        </button>
                                        <div class="uploader-list am-cf">

                                        </div>
                                    </div>
                                    <div class="help-block am-margin-top-sm">
                                        <small>尺寸750x750像素以上，大小2M以下 (可拖拽图片调整显示顺序 )</small>
                                    </div>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <div class="am-u-sm-9 am-u-sm-push-3 am-margin-top-lg">
                                    <button type="submit" class="j-submit am-btn am-btn-secondary">提交
                                    </button>
                                </div>
                            </div>
                        </fieldset>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!-- 图片文件列表模板 -->
{include file="layouts/_template/tpl_file_item" /}

<!-- 文件库弹窗 -->
{include file="layouts/_template/file_library" /}

{/block}
{block name="js-run"}
{encore:asset id="static/bundle/manage/js/art-template.js" type="js" /}
{encore:asset id="static/bundle/manage/js/ddsort.js" type="js" /}
<script>
  $(function () {
    /* 缓存设置 */

    $('.is_show_stock input').change(function(){
      var value = $(this).val();
      if(value == 1){
        show_stock_html();
      }else{
        $('.stock_html').remove();
      }
    });
    function  show_stock_html(){
      var socketHtml = template('coupon_stock_item');
      $('.is_show_stock').after(socketHtml);
    }

    /* 提醒设置 */

    $('.is_show_notice input').change(function(){
      var value = $(this).val();
      if(value == 1){
        show_notice_html();
      }else{
        $('.notice_html').remove();
      }
    });
    function  show_notice_html(){
      var noticeHtml = template('coupon_notice_item');
      $('.is_show_notice').after(noticeHtml);
    }

    /* 分销设置 */

    $('.is_show_distribute input').change(function(){
      var value = $(this).val();
      if(value == 1){
        show_distribute_html();
      }else{
        $('.distribute_html').remove();
      }
    });
    function  show_distribute_html(){
      var noticeHtml = template('coupon_distribute_item');
      $('.is_show_distribute').after(noticeHtml);
    }


    // 选择图片
    $('.upload-file').selectImages({
      name: 'coupon[img_url]'
      , multiple: false
    });

    // 图片列表拖动
    $('.uploader-list').DDSort({
      target: '.file-item',
      delay: 100, // 延时处理，默认为 50 ms，防止手抖点击 A 链接无效
      floatStyle: {
        'border': '1px solid #ccc',
        'background-color': '#fff'
      }
    });

    /**
     * 表单验证提交
     * @type {*}
     */
    $('#my-form').superForm({});

  });
</script>
{/block}

